package com.distribute.framework.core.sql;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Column implements java.io.Serializable{
	private static final Long serialVersionUID = -1L;
	
	public String name;
	public String comment;
	public Integer length;
	public Boolean notNull;
	public Boolean primary=false;//是否主键
	public Boolean unique = false;//是否唯一
	public Boolean key = false;//是否索引
	public Boolean like = false;//是否可以模糊查询
	public String input;
	public String type;
	public String sqlType;
	public String relate;
	
	
	public List<KeyVal> options=new ArrayList();
	
	public Column() {
		// TODO Auto-generated constructor stub
	}
	
	/**
	 * @param name
	 * @param comment
	 * @param length
	 * @param notNull
	 * @param like
	 * @param input
	 * @param type
	 * @param sqlType
	 */
	public static Column define(String name, String comment, Integer length,
			Boolean notNull, Boolean like, String input, String type,String sqlType,String relate) {
		Column column = new Column();
		column.name = name;
		column.comment = comment;
		column.length = length;
		column.notNull = notNull;
		column.like = like;
		column.input = input;
		column.type = type;
		column.sqlType = sqlType;
		column.relate = relate;
		return column;
	}



	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name = name;
	}
	public Integer getLength()
	{
		return length;
	}
	public void setLength(Integer length)
	{
		this.length = length;
	}
	public Boolean getNotNull()
	{
		return notNull;
	}
	public void setNotNull(Boolean notNull)
	{
		this.notNull = notNull;
	}
	public Boolean getPrimary()
	{
		return primary;
	}
	public void setPrimary(Boolean primary)
	{
		this.primary = primary;
	}
	public Class getJavaType()
	{
		try {
			return Class.forName(type);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		return null;
	}
	public String getType()
	{
		return type;
	}
	public void setType(String type)
	{
		this.type = type;
	}
	public String getSqlType()
	{
		return sqlType;
	}
	public void setSqlType(String sqlType)
	{
		this.sqlType = sqlType;
	}
	public String getComment() {
		return comment;
	}
	public void setComment(String comment) {
		this.comment = comment;
	}
	public Boolean getUnique() {
		return unique;
	}
	public void setUnique(Boolean unique) {
		this.unique = unique;
	}
	public Boolean getKey() {
		return key;
	}
	public void setKey(Boolean key) {
		this.key = key;
	}
	public Boolean getLike() {
		return like;
	}
	public void setLike(Boolean like) {
		this.like = like;
	}
	public String getInput() {
		return input;
	}
	public void setInput(String input) {
		this.input = input;
	}
	public List<KeyVal> getOptions() {
		return options;
	}
	public void setOptions(List<KeyVal> options) {
		this.options = options;
	}
	public Column addOption(KeyVal option) {
		this.options.add(option);
		return this;
	}
	public String getRelate() {
		return relate;
	}

	public void setRelate(String relate) {
		this.relate = relate;
	}
	
}